package com.cyrusInnovation.test.comparator;

import java.util.Comparator;

import com.cyrusInnovation.test.record.PersonRecord;

/**
 * Sorted by <code>Gender</code> (Females before Males) then LastName ascending
 * @author Al
 *
 */
public class FemaleB4MaleLastNameAscending implements Comparator<PersonRecord> {
	
	public LastNameDescending lastNameDescending = new LastNameDescending();

	public int compare(PersonRecord record1, PersonRecord record2) {
		int genderCompare = record1.getGender().compareTo(record2.getGender());
		if (genderCompare==0) {
			return -1*lastNameDescending.compare(record1, record2);  //LastName ascending
		}
		else {
			return genderCompare;
		}
	}
}
